package util.function;

import org.junit.Test;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;

public class Function_ {

    /**
     * ArrayList replaceAll 测试
     */
    @Test
    public void test1() {

        ArrayList<Integer> list = new ArrayList<>(Arrays.asList(1, 3, 2, 4, 5, 6, 7));

        // 大于3 替换为 0
        list.replaceAll(i -> {
            if (i > 3) return 0;
            return i;
        });
        System.out.println(list.toString());

        //删除 0
        list.removeIf(i -> i == 0);

        System.out.println(list.toString());


        //排序
        list.sort(Comparator.comparingInt(a -> a));

        //forEach
        list.forEach(System.out::println);

        //Runnable 没有参数
        new Thread(() -> System.out.println(1));
    }

}
